﻿HmJS.$Import('core.core');

/*
---
name: Array.Hex
version: 0.3-1
description: Array Hex encode
license: MIT-style
download: http://mootools.net/forge/p/string_cryptography
source: http://github.com/sixtyseconds/mootools-string-cryptography
authors: [Christopher Pitt, Enrique Erne]
requires: 
- Core/Array
provides: [Array.toHex]
...
*/

HmJS.register('crypt.array.cryptographyhex', function ($ns) {

	Array.implement({
		'toHex': function (hexUpperCase) {
			var result = '',
					chars = hexUpperCase ? '0123456789ABCDEF' : '0123456789abcdef';

			for (var a = 0, l = this.length * 4; a < l; a++) {
				result += chars.charAt((this[a >> 2] >> ((3 - a % 4) * 8 + 4)) & 0xF) + chars.charAt((this[a >> 2] >> ((3 - a % 4) * 8)) & 0xF);
			}

			return result;
		}
	});

});